package util;

public class Token {
    public int type;
    public String text;
    public int row;
    public int col;


    public Token(int type, String text, int row, int col) {
        this.type = type;
        this.text = text;
        this.row = row;
        this.col = col;
    }

    public Token(int type, String text) {
        this(type, text, -1, -1);
    }

    public String getTypeName() {
        return TokenType.names[type];
    }

    @Override
    public boolean equals(Object o) {
        throw new UnsupportedOperationException("未实现 equals");
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Token token = (Token) o;
//        return Objects.equals(this.type, token.type) && Objects.equals(this.text, token.text) && Objects.equals(this.row, token.row) && Objects.equals(this.col, token.col);
    }

    @Override
    public int hashCode() {
        throw new UnsupportedOperationException("未实现 hashCode");
    }

    @Override
    public String toString() {
        return String.format("<%s, %s, %s, %s>", getTypeName(), text, row, col);
    }
}
